//
//  MYWelcomViewController.swift
//  NewMicroblog
//
//  Created by apple on 2016/10/25.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit
import SDWebImage

class MYWelcomViewController: UIViewController {
    override func loadView() {
        view = bgImgV
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        self.imaView.snp_updateConstraints { (make) in
            make.top.equalTo(view).offset(100)
        }
        UIView.animate(withDuration: 1, delay: 1, usingSpringWithDamping: 0.7, initialSpringVelocity: 0, options: [], animations: { 
            
          self.view.layoutIfNeeded()
            }) { (_) in
                UIView.animate(withDuration: 0.25, animations: { 
                    self.messaLabel.alpha = 1
                    }, completion: { (_) in
                        NotificationCenter.default.post(name: NSNotification.Name(rawValue:MYROOTCONTROLLERVC), object: "wel")
                })
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        setupUI()
    }
    
    private func setupUI(){
        view.addSubview(imaView)
        view.addSubview(messaLabel)
        imaView.snp_makeConstraints { (make) in
            make.size.equalTo(CGSize(width: 90, height: 90))
            make.centerX.equalTo(view)
            make.top.equalTo(view).offset(400)
        }
        messaLabel.snp_makeConstraints { (make) in
           make.centerX.equalTo(view)
            make.top.equalTo(imaView.snp_bottom).offset(16)
        }
    }
    
    
    private lazy var bgImgV: UIImageView = UIImageView(imageName: "ad_background")
    
    private lazy var imaView: UIImageView = {
        let imgv = UIImageView()
        imgv.layer.borderColor = ORANGE.cgColor
        imgv.layer.borderWidth = 1
        imgv.layer.cornerRadius = 45
        imgv.layer.masksToBounds = true
        imgv.my_setImage(urlStr:MYUserinfoViewModel.sharedModel.userInfoModel?.avatar_large, placeholderImgName: "avatar_default_big")
        return imgv
    }()
    private lazy var messaLabel: UILabel = {
        let label = UILabel(title: "欢迎回来", fontSize: 18, textColor: ORANGE)
        label.textAlignment = .center
        label.alpha = 0
        return label
    }()

}
